package cn.gogpay.duoim.sdk.exception;

import cn.gogpay.duoim.sdk.constant.IMRespCode;

public class IMSDKException extends RuntimeException {

    private final IMRespCode response;

    public IMSDKException() {
        super(IMRespCode.error().getMessage());
        response = IMRespCode.error();
    }

    public IMSDKException(IMRespCode response) {
        super(response.getMessage());
        this.response = response;
    }

    public IMSDKException(IMRespCode response, String message) {
        super(message);
        this.response = new IMRespCode(response.getCode(), message);
    }

    public IMSDKException(Integer code, String message) {
        super(message);
        this.response = new IMRespCode(code, message);
    }

    public IMSDKException(String message) {
        super(message);
        this.response = new IMRespCode(IMRespCode.error().getCode(), message);
    }

    public IMRespCode getResponse() {
        return response;
    }

    @Override
    public String toString() {
        return this.response.toString();
    }
}
